<{include file="tpl/admin/header.html"}>
<script src="tpl/admin/src/js/jscal2.js"></script>
<script src="tpl/admin/src/js/unicode-letter.js"></script>
<script src="tpl/admin/src/js/lang/cn.js"></script>
<script src="kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>
<script>
var editor;
KindEditor.ready(function(K) {
	editor = K.create('textarea[name="content"]', {
		allowFileManager : true
	});
	K('input[name=getHtml]').click(function(e) {
		alert(editor.html());
	});
	K('input[name=isEmpty]').click(function(e) {
		alert(editor.isEmpty());
	});
	K('input[name=getText]').click(function(e) {
		alert(editor.text());
	});
	K('input[name=selectedHtml]').click(function(e) {
		alert(editor.selectedHtml());
	});
	K('input[name=setHtml]').click(function(e) {
		editor.html('<h3>Hello KindEditor</h3>');
	});
	K('input[name=setText]').click(function(e) {
		editor.text('<h3>Hello KindEditor</h3>');
	});
	K('input[name=insertHtml]').click(function(e) {
		editor.insertHtml('<strong>插入HTML</strong>');
	});
	K('input[name=appendHtml]').click(function(e) {
		editor.appendHtml('<strong>添加HTML</strong>');
	});
	K('input[name=clear]').click(function(e) {
		editor.html('');
	});
});
</script>
<link rel="stylesheet" type="text/css" href="tpl/admin/src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="tpl/admin/src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="tpl/admin/src/css/steel/steel.css" />
<script type="text/javascript">
$(document).ready(function(){ // 当页面加载完毕的时候
	// 例子三
	$("#ex3button").click(function(){ // "提交"按钮被点击
		// 构造发送的数据，请注意如果获取表单各项的值
		var formdata = {
			'id' : $('#id').val(),
			'title' : $('#title').val(),
			'username' : $('#username').val(),
			'picurl' : $('#picurl').val(),
			'releasedate' : $('#releasedate').val(),
			'content' : editor.html(),
			'classid' : $('#classid').val()
		};
		var id  = $('#id').val();  // 根据有没有id 判断是编辑还是增加
		if(id == '')
		{
			// 用$.post发送数据
			$.post('<{spUrl c=messageinfoform a=adddata}>', formdata, function(result){
                $('#resulttable').append(result);
                feedback(result,id);
			});
		}
		else
		{
		   	// 用$.post发送数据
			$.post('<{spUrl c=messageinfoform a=editdata}>', formdata, function(result){
				$('#resulttable').append(result); // 返回的数据直接追加到resulttable表格的后面
				feedback(result,id);
			});	
		}
		
	});
});

function del(id){
		$.get('<{spUrl c=messageinfoform a=deldata}>', 'id='+id, function(result){
			$('#ex1result').html(result); // 返回的数据直接显示在id=ex1result的span中。
			if(result == 1)
			{alert('删除成功!!');}else{alert('删除失败!!')}
			window.location.reload(); 
		});
}

// 搜索功能调用
function searchs(){
	var filter = $('#filter').val();
	if(filter != ''){
	  window.location.href="index.php?c=messageinfoform&a=index&t=message&filter="+filter+"";
	}
}

// 分类列出
function Class(nums){
	var filter = $('#filter').val();
	if(nums.value != '')
	{window.location.href="index.php?c=messageinfoform&a=index&t=message&classid="+nums.value+"&filter="+filter+"";}
}
</script>
<div class="breadcrumbs">
	<div class="container-fluid">
		<ul class="bread pull-left">
			<li>
				<a href="index.php?c=manage&a=index"><i class="icon-home icon-white"></i></a>
			</li>
			<li>
				<a href="index.php?c=messageinfoform&a=index&t=message">
					内容管理
				</a>
			</li>
		</ul>

	</div>
</div>
<div class="main">
    <{include file="tpl/admin/left.html"}>
	<div class="container-fluid">
		<div class="content">
			<div class="row-fluid">
				<div class="span12">
					<div class="box">
						<div class="box-head tabs">
							<h3>内容管理 | <a href="index.php?c=messageinfoform&a=index&t=message">添加</a></h3>
							<ul class='nav nav-tabs'>
								<li class='active'>
									<a href="#basic" data-toggle="tab">Basic</a>
								</li>
								<li>
									<a href="#nohead" data-toggle="tab">No header</a>
								</li>
							</ul>
						</div>
						<div class="box-content box-nomargin">
							<div class="tab-content">
									<div class="tab-pane active" id="basic">
										<table class='table table-striped dataTable table-condensed table-bordered'>
                                        	  <thead>
                                                <th>编号</th>
                                                <th>图片</th>
                                                <th>标题</th>
                                                <th>分类</th>
                                                <th>发布人</th>
                                                <th>时间</th>
                                                <th>操作</th>
                                              </thead>
											<tbody>
                                              <{foreach item=resultsname from=$results key=enname}>
                                                <tr>
                                                 <td><{$resultsname.id}></td>                                                 
                                                 <{if $resultsname.picurl != ''}>
                                                 <td><a target="_blank" href="<{$resultsname.picurl}>">
                                                 <img src="<{$resultsname.picurl}>" width="18" height="18">
                                                 </a>
                                                 </td>
                                                 <{else}>
                                                  <td>无</td>
                                                 <{/if}>
                                                 <td><{$resultsname.title}></td>
                                                 <td><{$resultsname.classid}></td>
                                                 <td><{$resultsname.username}></td>
                                                 <td><{$resultsname.releasedate|date_format:"%Y-%m-%d:%H:%M:%S"}></td>
                                                 <td><a href="index.php?c=messageinfoform&a=index&t=message&id=<{$resultsname.id}>#mao">编辑</a> | <a href="javascript:del(<{$resultsname.id}>);">删除</a></td> 
                                                </tr>
                                              <{/foreach}>
											</tbody>
										</table>
									</div>
									<div class="tab-pane" id="nohead">
										<table class='table table-striped dataTable dataTable-noheader table-bordered'>
											<thead>
												<tr>
                                                <th>编码</th>
                                                <th>图片</th>
                                                <th>标题</th>
                                                <th>分类</th>
                                                <th>发布人</th>
                                                <th>时间</th>
                                                <th>操作</th>											
                                                </tr>
											</thead>
											<tbody>
                                              <{foreach item=resultsname from=$results key=enname}>
                                                <tr>
                                                 <td><{$resultsname.id}></td>
                                                 <td><{$resultsname.picurl}></td>
                                                 <td><{$resultsname.title}></td>
                                                 <td><{$resultsname.classid}></td>
                                                 <td><{$resultsname.username}></td>
                                                 <td><{$resultsname.releasedate}></td>
                                                 <td><a href="index.php?c=messageinfoform&a=index&t=message&id=<{$resultsname.id}>">编辑</a> | <a href="javascript:del(<{$resultsname.id}>);">删除</a></td> 
                                                </tr>
                                              <{/foreach}>											
                                           </tbody>
                                           <tr>
                                              <td>fdsfds</td>
                                           </tr>
										</table>
									</div>

							</div>
						</div>
					</div>
				</div>
			</div>
            
            			<div class="row-fluid">
				<div class="span12">
					<div class="box">
						<div class="box-head">
							<h3>数据高级检索</h3>
						</div>
						<div class="box-content">
							<form action="#" class="form-horizontal">
								<fieldset>
									<div class="control-group">
										<label for="tags" class="control-label">高级搜索</label>
										<div class="controls">
                                             <div class="input-append">
                                              <input style="width:350px;" class="span8" id="filter" type="text">
                                              <button onclick="searchs()" class="btn" type="button">开始搜索</button>
                                             </div>
										</div>
									</div>
									<div class="control-group">
										<label for="selsear" class="control-label">分类检索</label>
										<div class="controls">
                                           <select onchange="Class(this)" name="classid" id="classid">
                                               <option selected value="0">根目录</option>
                                               <{foreach item=classname from=$resultclass key=enname}>
                                                 <{if $sclassid == $classname.id}>
                                                    <option selected value="<{$classname.id}>">
                                                    <{$classname.cname}></option>
                                                 <{else}>
                                                    <option value="<{$classname.id}>"><{$classname.cname}></option>
                                                 <{/if}>
                                               <{/foreach}>
                                            </select>
										</div>
									</div>
								</fieldset>
							</form>
						</div>
					</div>
				</div>
			</div>

            <div class="row-fluid">
				<div class="span12">
					<div class="box">
						<div class="box-head">
					
                           <{if $uid != 0}>
                              <h3>编辑数据</h3>
                           <{else}>
                              <h3>增加数据</h3>
                           <{/if}>
						</div>
						<div class="box-content">
							<a href="" name="mao"></a>
							<form action="#" class='validate form-horizontal'>
                                <div class="control-group">
                                   <label for="req" class="control-label">文章名称：</label>
                                   <div class="controls">
                                   <input type="text" name="title" id="title" value="<{$title}>">
                                   <span></span>
                                  </div>
                                </div>
                                
                              <div class="control-group">
									<label for="req" class="control-label">文章分类：</label>
									<div class="controls">
                                       <select name="classid" id="classid">
                                           <option selected value="0">根目录</option>
                                           <{foreach item=resultclassname from=$resultclass key=enname}>
                                             <{if $classid == $resultclassname.id}>
                                                <option selected value="<{$resultclassname.id}>"><{$resultclassname.cname}></option>
                                             <{else}>
                                                <option value="<{$resultclassname.id}>"><{$resultclassname.cname}></option>
                                             <{/if}>
                                           <{/foreach}>
                                        </select>
                                        <span></span>
                                  </div>
								</div>
                                
                                <div class="control-group">
                                   <label for="req" class="control-label">发布人：</label>
                                   <div class="controls">
                                   <input type="text" name="username" id="username" value="<{$username}>">
                                   <span></span>
                                  </div>
                                </div>
                                
                               <div class="control-group">
                                   <label for="req" class="control-label">图片地址：</label>
                                   <div class="controls">
                                   <input type="text" name="picurl" id="picurl" value="<{$picurl}>">
                                   <span></span>
                                  </div>
                                </div>
                                
                                <div class="control-group">
                                   <label for="req" class="control-label">时间：</label>
                                   <div class="controls">
                                   <input type="text" name="releasedate" id="releasedate" value="<{$releasedate}>">
                                   <span></span>
								   <script type="text/javascript">//<![CDATA[
                                    Calendar.setup({
                                      inputField : "releasedate",
                                      trigger    : "releasedate",
                                      onSelect   : function() { this.hide() },
                                      showTime   : 24,
                                      dateFormat : "%Y-%m-%d %H:%M:%S"
                                    });
                                  //]]>
                                  </script>
                                  </div>
                                </div>
                                
                              <div class="control-group">
                                   <label for="req" class="control-label">内容：</label>
                                   <div class="controls">
                                   <textarea name="content" id="content" style="width:700px;height:400px;visibility:hidden;"><{$content}></textarea>
                                   <span></span>
                                  </div>
                                </div>
                                
						<div class="form-actions">
								  <input type="button" id="ex3button" value="提交" class='btn btn-primary'>
                                  <input type="hidden" name="id" id="id" value="<{$id}>">
						</div>
							</form>
						</div>
					</div>
				</div>
                
		</div>	
	</div>
</div>	
<{include file="tpl/admin/footer.html"}>